package com.example.paimengshop;

import com.example.paimengshop.client_socket.SendToServer;
import com.example.paimengshop.client_socket.SocketConnect;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;

import java.io.IOException;
import java.net.ConnectException;
import java.net.Socket;

import static java.lang.System.exit;


public class main extends Application {

    private static SendToServer send = null;

    public static void setSend(SendToServer send)
    {
        main.send = send;
    }

    public static SendToServer getSend()
    {
        return send;
    }

    private static customerServiceController customerServiceController;

    private static AccountController accountController;

    public static void setAccountController(AccountController accountController)
    {
        main.accountController = accountController;
    }

    public static AccountController getAccountController()
    {
        return accountController;
    }

    public static void setCustomerServiceController(com.example.paimengshop.customerServiceController customerServiceController)
    {
        main.customerServiceController = customerServiceController;
    }

    public static com.example.paimengshop.customerServiceController getCustomerServiceController()
    {
        return customerServiceController;
    }

    @Override
    public void start(Stage stage) throws IOException
    {
        FXMLLoader fxmlLoader = new FXMLLoader(main.class.getResource("mainUnlogin.fxml"));
        Scene scene = new Scene(fxmlLoader.load());
        stage.setTitle("派蒙的周边商铺!");
        stage.setScene(scene);
        stage.show();

        try
        {
            Socket socket = new Socket("127.0.0.1", 8080);
            send = new SendToServer(socket);
            new SocketConnect(socket).Connect();
        }
        catch (ConnectException e)
        {
            exit(-1);
        }
    }

    public static void main(String[] args) {
        launch();
    }
}